<?php
include 'common/autoload.php';
include 'common/Prod_Common.php';
include 'common/prodField.php';
use pft\Prod\Product;
$titleText = '新增门票';
$navText = '新增门票';
$gourl = $background ? 2 : 1;
$isedit = false;
$iscopy = $_GET['act'] && $_GET['act']=='copy' ? 1:0;
$obj = new Product($GLOBALS['le']);
$sid = abs($_GET['sid']);//景区ID
//echo $sid;
$ticket_id = abs($_GET['prod_id']);//产品ID
if(!$sid && !$ticket_id) {
    echo '<script>alert("访问参数出错");history.go(-1);</script>';
    exit;
}
if($iscopy) {
    $otherParams = '&act=copy&c_title=' .urlencode($_GET['c_title']);
}
$apply_did = $_SESSION['dtype']==6? $_SESSION['sid'] : $_SESSION['memberID'];
if($_SESSION['dtype']==6) {
    if(\pft\Member\MemberAccount::GetMemType($_SESSION['sid'])!=0) {
        exit('您的上级不是供应商身份，无法发布产品。');
    }
}
elseif($_SESSION['dtype']!=0 && $_SESSION['dtype']!=9) {
    exit('您不是供应商身份，无法发布产品。');
}
if($ticket_id) {
    $isedit = true;
    $ticket_id = abs($_GET['prod_id']);//门票id
    if($_SESSION['dtype']==9) {
        $data = $obj->GetTicketById($ticket_id);
    }
    else {
        $data = $obj->GetTicketById($ticket_id, $apply_did);
    }
//    print_r($data);
    $apply_did = $data['apply_did'];
    $data_f = $obj->GetProdcutExt($ticket_id );//扩展表里面的数据
    $ass = '';//集合地点
    if($data_f['ass_station']){
        $ass = implode(';',unserialize($data_f['ass_station']));
    }
//    $sid = $data['landid'];
//    echo $data['landid'];
    $tid = $data['id'];
    $pid = $data['pid'];
    $pobj = new Price($pid);
    $titleText = $data['title'];
    $navText = '门票编辑';
    $startplace = $data_f['startplace'];
    $endplace = $data_f['endplace'];
}
$scenryData = $obj->GetSceneryTitle($sid);
$ptype = $scenryData['p_type'];
$notify_num = $scenryData['fax'];
if($ptype=='B' && !$ticket_id) {
    $startplace = substr($scenryData['runtime'],0,strpos($scenryData['runtime'],'|'));
    $endplace = substr($scenryData['runtime'],strpos($scenryData['runtime'],'|')+1);
}

$titleText = $scenryData['title'].'--'.$titleText;

if($background && $data['apply_limit']==0){
    $btnWrap = '<button class="ui-button ui-button-lorange" id="ProdRefuse" type="button">拒绝该申请</button>&nbsp;';
    $btnWrap .= '<button class="ui-button ui-button-lblue" id="ProdPass" type="button" title="保存门票信息并通过审核">通过审核</button>&nbsp;';
}
else {
    $btnWrap = '<button class="ui-button ui-button-lblue" id="saveTicket" type="button">保存</button>';
}

// 需要绑定闸机的产品ID（tid）
$needBind = array(
	'1976',	'4314',	'4313',	'5604',	'5603',	'5523',	'5522',	'5521',	'5520',	'3950',	'3949',	'3911','5857','5818','5817','5816','6047','6049','5959','5958','5957','6060','6059','6062','6061','6044','6042','4313','4314','5567','7177','9746','6042','6044','9833','9832','9962','10003','9962','9963','9964','9965','9904','9948','9949','9901',
'9873','9874','9862','9863','9836','9837','9855','9856','9830','9831','9829','9826','9809','9810','9811','9812','10004'

);
if(in_array($_REQUEST['prod_id'],$needBind)){
	// 绑定闸机票类数据
	// $jiuTian = file_get_contents('http://bj.doswalker.com/et/ebusiness/ticketInfo.do');
	// $jiuTian = json_decode($jiuTian);
	$tmp = array();
	$md5 = md5($scenryData['title'].'-'.$_REQUEST['prod_id']);
	$jiuTians[] = array('uuid'=>$md5,'name'=>$data['title']);
}
if($_SESSION['sid'] == 7517 ){
	// 绑定闸机票类数据
	$jiuTians = file_get_contents('http://117.29.178.154:8000/et/ebusiness/ticketInfo.do');
	$jiuTians = json_decode($jiuTians,true);
    $jiuTians = $jiuTians['content'];
}
/*
<?foreach($jiuTian->content as $var):?>
	<?if($data['uuid']==$var->uuid):?>
	<option value="<?=$var->uuid?>" selected="selected"><?=$var->name?></option>
	<?else:?>
	<option value="<?=$var->uuid?>" ><?=$var->name?></option>
	<?endif?>
<?endforeach?>
*/
$page_title = "票类编辑 - ";
include 'common/header.html';
include 'common/left.html';

?>
<link rel="stylesheet" href="http://www.12301.cc/css/aliceui.min.css"/>
<link rel="stylesheet" href="http://www.12301.cc/css/resetui.css"/>
<link rel="stylesheet" href="http://www.12301.cc/css/product_publish.css?body=1"/>
<link rel="stylesheet" href="http://www.12301.cc/css/prod_store.css"/>
<link rel="stylesheet" href="http://www.12301.cc/css/my_color.css"/>
<link rel="stylesheet" href="http://www.12301.cc/css/easydialog.css"/>
    <div class="wrapper">
    <h3 class="mc_title">
        <span class="mctit_1"><span class="mctit_2">票类编辑</span></span>
    </h3>
    <?if(!$isedit){?>
        <ol class="ui-ministep step3">
            <li class="ui-ministep-item">
                <span class="ui-ministep-text">产品类型</span>
            </li>
            <li class="ui-ministep-item">
                <span class="ui-ministep-text"><?=$FieldList[$ptype]['ticket']['t4']?></span>
            </li>
            <li class="ui-ministep-item ui-ministep-active">
                <span class="ui-ministep-text"><?=$FieldList[$ptype]['ticket']['t1']?></span>
            </li>
        </ol>
    <?}?>
    <form class="ui-form" name="branchForm" id="branchForm">
    <input type="hidden" name="did" value="<?=$apply_did?>">
    <input type="hidden" name="lastid" value="<?=$sid?>"/>
    <input type="hidden" name="action" value="CreateNewTicket"/>
    <input type="hidden" name="f[fid]" value="<?=$data_f['id']?>"/>
    <input type="hidden" name="step" value="2"/>
    <input type="hidden" name="ptype" value="<?=$ptype?>"/>
    <input type="hidden" name="chk_state" value="<?=$data['apply_limit']?>"/>
    <input type="hidden" name="pid" value="<?=$data['pid']?>"/>
    <input type="hidden" name="tid" value="<?=$data['id']?>"/>
    <input type="hidden" name="ser_date" value="<?=date('Ymd')?>"/>
    <input type="hidden" name="pft_rflex_id" value="<?=$data['pft_rflex_id']?>"/>
    <input type="hidden" name="iscopy" value="<?=$iscopy?>"/>
    <?=$saveByAdminInput?>
    <div class="ui-tipwrap" id="RefuseMsgWrapper">
        <div class="ui-tipbox ui-tipbox-error">
            <div class="ui-tipbox-content">
                <h3 class="ui-tipbox-title"></h3>
                <p class="ui-tipbox-explain" id="RefuseReason"></p>
            </div>
        </div>
    </div>
    <?
    if($ptype=='F') {
        $package_data = $scenryData['attribute'];
        $package_data = $obj->PackageDataFormat($package_data);
		include_once("class/ProductInfo.php");//
		include("class/Member.php");
		$ac=$GLOBALS['_ac'];
		$pw=$GLOBALS['_pw'];
		$s = new SoapClient(null,array("location" => "http://localhost/open/openService/pft_insideMX.php","uri" => "www.16u.com?ac_16u=$ac|pw_16u=$pw|auth_16u=true"));
		$proObj = new ProductInfo($s,0,0);
		$proPri = new Price(-1);
		$m=new Member($s,$_SESSION['memberID']);

		$pInfoArr = array();
		// 获取关联的产品信息
		
		foreach($package_data as $val){
			$pInfoArr[] = $proObj->pinfo($val['pid']);
		}
		// print_r($pInfoArr);
		// exit;
		// 验证之间的属性
		$errMsg=array();
		$payModel = $pInfoArr[0]['pay'];// 支付方式
		// $tourist_info = $pInfoArr[0]['tourist_info'];// 游客信息
		$advance = $pInfoArr[0]['ddays'];// 提前购买天数
		$effective = $pInfoArr[0]['ddays']+$pInfoArr[0]['delaydays'];// 有效期最小值
		$priceArr = array();// 价格存储数组
		$minActiveArr = array();// 存储有效期
		// print_r($pInfoArr);
		
		
		$maxSetDate = date('Y-m-d');// 设置票类适用时间最大值
		$minSetDate = date('Y-m-d');// 设置票类适用时间最小值

		foreach($pInfoArr as $k=>$val){
			if($payModel!=$val['pay']){	$errMsg[]='支付方式不一致';break;}
			// if($val['tourist_info']!=$tourist_info){$errMsg[]='游客信息不一致';break;}
			if($val['ddays'] && ($advance<$val['ddays'])){//提前天数不一致
				$advance = $val['ddays'];
			}
			
			
			$active =  $val['ddays']+$val['delaydays']; // 当前票有效期
			// $minActiveArr[] = $active;
			$minActiveArr[] = $val['delaydays'];
			if($active < $effective) $effective = $active;
			// 判断提前天数大于有效期，那么就有一张不能用
			
			if($advance>$effective){
				$errMsg[]='套票产品须提前'.$advance.'天，有部分产品失效。';break;
			}
			// 默认结算价+零售价
			$tmp = $m->salePros($val['lid']);
			// print_r($tmp);
			foreach($tmp as $v){
				if($v['pid']==$val['pid']){
					$arr = array(
						'jsprice'=>$v['jsprice'],
						'uprice'=>$v['uprice']
					);
					$priceArr[$val['pid']]=$arr;
					continue;
				}
			}

			
			// 计算时间交集
			$xml = $proPri->GetDynamicPrice('', 0, date('Y-m-d'),'',0,1,$val['pid']);
			$obj = (array)simplexml_load_string($xml);
			// print_r($obj);
			
			// echo count($obj);
			// if(count($obj['Rec'])){
			
			// }
			if(is_object($obj['Rec'])){
				$tmpbegin = $obj['Rec']->UUstart_date;
				$tmpend = $obj['Rec']->UUend_date;
			}else{
				$tmpbegin = (string)$obj['Rec'][0]->UUstart_date;
				$tmpend = (string)$obj['Rec'][0]->UUend_date;
				foreach($obj['Rec'] as $v){
					if((string)$v->UUstart_date<$tmpbegin)$tmpbegin = $v->UUstart_date;
					if((string)$v->UUend_date<$tmpend)$tmpend = $v->UUend_date;
				}
			}
			// echo $
			if($tmpbegin>$minSetDate) $minSetDate = $tmpbegin;
			if($maxSetDate<$tmpend) $maxSetDate = $tmpend;
	}
	
		$pos = array_search(min($minActiveArr), $minActiveArr);
		// $minActive = $minActiveArr[$pos]-$advance;
		$minActive = $minActiveArr[$pos];
		// 能提前的天数
		// echo $advance;
		// echo $minActive;
		
		// 获取默认价格
		$jsprice=$uprice=0;
		foreach($package_data as $val){
			$jsprice+=$val['num']*$priceArr[$val['pid']]['jsprice'];
			$uprice+=$val['num']*$priceArr[$val['pid']]['uprice'];
		}
        include TPLPATH .'_package_box.html';
		if(count($errMsg)){
			echo $errMsg[0];
			exit;
		}
		// if($data['ddays']>$advance){
			// echo '<script>alert("b")</script>';
		// }
		// if($data['delaydays']>$minActive){
			// echo '<script>alert("a")</script>';
		// }
	}
	// echo $data['ddays'],$advance;
    ?>
	<input type="hidden" value="<?=$minSetDate?>" class="minDateTarget"/>
	<input type="hidden" value="<?=$maxSetDate?>" class="maxDateTarget"/>
	<input type="hidden" name="ptype" value="<?=$ptype?>"/>
    <table id="pros_tbl" class="prod_laun">
        <caption>
            <h3>产品名：<?=$scenryData['title']?></h3>
        </caption>
        <thead>
        <tr class="header">
            <th colspan="2" class="th_n">常用属性</th>
        </tr>
        </thead>
        <tbody class="fixed_th_width">
        
    <tr>
        <th id="th_1">付款方式</th>
        <td data-hide="<?=$data['pay']?>">
            <label><input type="radio" class="vn_middle" value="1" <?=($data['pay']==1)?'checked="checked"':''?> name="payType" id="payType1" />在线支付</label>
            <input type="text" class="input-text w40 chknum" name="cancel_time" value="<?=$data['cancel_auto_onMin']?>">分钟未支付则不能支付&nbsp;&nbsp;
			<!--
            <label><input type="radio" class="vn_middle" value="0" <?=($data['pay']==0)?'checked="checked"':''?> name="payType" onChange="evolution_check(this,<?=$data['pid']?>)" />现场支付</label>
			-->
        </td>
    </tr>
    <input type="hidden" class="effectiveTime" name="vt" value="<?=isset($minActive)?$minActive:0;?>"/>
    <input type="hidden" class="delaytype" name="validTime" value="1"/>
    <tr>
        <th id="th_3">提前预定</th>
        <td>
            <span class="ui-form-explain">
			<input type="hidden" class="earyDay" value="<?=isset($advance)?$advance:0?>"/>
                需提前<input type="text" class="input-text w40 chknum" name="earyTime" value="<?=isset($data['ddays'])?$data['ddays']:$advance?>">天，在
                <select name="f[dhour]">
                    <?for($i=23;$i>=0;$i--){?>
                        <option value="<?=$i?>" <?=isset($data_f['dhour']) && substr($data_f['dhour'],0,-4)==$i?'selected="selected"':''?>><?=$i.':59'?></option>
                    <?}?>
                </select>前预定
            </span>
        </td>
    </tr>
    <?if($ptype=='A' || $ptype=='F'){?>
        <!--门票属性-->
        <tr>
            <th id="th_6"><span class="ui-form-required">*</span>取票信息</th>
            <td>
                <input type="text" value="<?=$data['getaddr']?>" title="请输入取票信息" name="TicketInfo" class="input-text w500" data-required="1">
                <span class="ui-form-explain">此信息将在游客手机短信上显示</span>
            </td>
        </tr>
        <tr>
            <th id="th_7">产品说明</th>
            <td>
                <textarea name="TicketExplain" class="input-text w500" style="height: 50px;"><?=$data['notes']?></textarea>
            </td>
        </tr>
        <!--门票属性-->
    <?}?>
    <?if($ptype=='B'){?>
        <!--线路属性-->
        <tr>
            <th>
                <span class="ui-form-required">*</span>游玩天数
            </th>
            <td>
                <input class="input-text w40 chknum" data-required="1" title="请输入游玩天数" type="text" name="f[rdays]" id="tourDays" value="<?=$data_f['rdays']?>">天
                <span class="ui-form-explain">请填写大于0的数字</span>
                <input class="input-text" name="f[beginPlace]" id="beginPlace"  type="hidden" placeholder="出发地" value="<?=$startplace?>">
                <input class="input-text" name="f[endPlace]" type="hidden" placeholder="目的地" value="<?=$endplace?>">
            </td>
        </tr>
        <tr>
            <th>团号</th>
            <td>
                <?
                $prefix = substr($data_f['series_model'],0, strpos($data_f['series_model'],'{'));
                $endfix = substr($data_f['series_model'],strpos($data_f['series_model'],'}')+2);
                ?>
                <input type="text" name="grp_num1" class="grp_num input-text w50" value="<?=$prefix?>"/>
                +出团日期+出团编号
                <select name="grp_num2" class="grp_num">
                    <option value="">选择</option>
                    <?for($i=1;$i<=10;$i++){ $code = str_pad($i, 2,'0',STR_PAD_LEFT);?>
                        <option value="<?=$code?>" <?=$endfix==$code?'selected="selected"':''?>><?=$code?></option>
                    <?}?>
                </select>
                预览：<span id="prev_grp_num"><?=!empty($data_f['series_model'])?str_replace('{fck_date}', date('Ymd'),$data_f['series_model']):''?></span>
            </td>
        </tr>
        <tr>
            <th><span class="ui-form-required">*</span>集合地点</th>
            <td>
                <textarea cols="100" rows="4" id="ass_station" name="f[ass_station]"><?=$ass?></textarea>
                <p class="ui-form-explain">填写集合地点、集合时间及导游手机，<span class="red">多个集合地点请用<strong>分号</strong>（;）分隔</span></p>
            </td>
        </tr>
        <!--线路属性-->
    <?}?>
    <tr>
        <th id="th_0"><span class="ui-form-required">*</span><?=$FieldList[$ptype]['ticket']['ticketType']?></th>
        <td>
            <input type="text" name="tTitle" class="input-text w300" data-required="1" title="请输入<?=$pname?>名称" value="<?=!empty($_GET['c_title'])?urldecode($_GET['c_title']):$data['title']?>">
			<?if(in_array($_REQUEST['prod_id'],$needBind) || $_SESSION['sid'] == 7517):?>
			<span class="ui-form-required">*</span>
			<span>关联线下票类</span>
			<select name="gate">
				<option value="" > 请选择 </option>
                <?foreach($jiuTians as $key=>$jiuTian):?>
                    <?if($data['uuid']==$jiuTian['uuid']):?>
                    <option value="<?=$jiuTian['uuid']?>" selected="selected"><?=$jiuTian['name']?></option>
                    <?else:?>
                    <option value="<?=$jiuTian['uuid']?>" ><?=$jiuTian['name']?></option>
                    <?endif?>
                <?endforeach;?>
			</select>
			<?endif?>
        </td>
    </tr>
    </tbody>
    </table>
    <table class="prod_laun">
        <thead>
        <tr class="header">
            <th class="th_n">扩展属性</th>
            <td class="td_n"></td>
        </tr>
        </thead>
        <tbody class="fixed_th_width">
        <tr>
            <th>销售对象</th>
            <td>
               <?=GetHtmlSelect($ProvideTo,'provide_to',$data['p_status']);?>
            </td>
        </tr>
        <tr>
            <th>取消费用</th>
            <td>
				 <span class="number_style"><select id="testtt" onchange="check()" name="reb_type">
                    <option value="0">售价百分比</option>
                    <option value="1" <?if($data['reb_type']==1) echo 'selected="selected"'?>>固定金额</option></select>
                </span>
                <input type="text" name="reb" class="input-text w40 chknum" value="<?=($data['reb_type'])?  $data['reb']/100:$data['reb']?>"/>
                <span id="num_style">%</span>
                <span id="yuan_style">元</span>
               
                <span class="ui-form-explain">取消订单需要收取的费用百分比，填“0”代表不收取费用。</span>
            </td>
        </tr>
        <tr>
            <th>身份证验证</th>
            <td>
                <label><input type="radio" class="vn_middle" value="0" <?=!isset($data_f)||$data_f['v_ID_support']==0?'checked="checked"':''?> name="f[v_ID_support]" />不支持</label>
                <label><input type="radio" class="vn_middle" onclick="return confirm('您确定终端已经支持身份证验证了吗？')" value="1" <?=$data_f['v_ID_support']==1?'checked="checked"':''?> name="f[v_ID_support]" />支持</label>
                <span class="ui-form-explain">开启身份证验证需终端支持。</span>
            </td>
        </tr>
        <tr>
            <th>短信通知</th>
            <td>
                <label><input type="radio" name="f[confirm_sms]" value="0" <?=!$data_f['confirm_sms']?'checked="checked"':''?>/>否</label>
                <?php
                    if(!isset($data)){
                        $dis_sms = 'disabled="disabled"';
                        $dis_sms_cl = 'disable';
                    }
                    if(isset($data_f['confirm_sms']) && $data_f['confirm_sms']==1){
                        $chk_sms = 'checked="checked"';
                    }
                ?>
                <label class="<?=$dis_sms_cl?>"><input type="radio" name="f[confirm_sms]" value="1" <?=$chk_sms?> <?=$dis_sms?>/>是</label>
                <span class="ui-form-explain">新订单是否短信通知供应商</span>
                通知手机： <input type="text" maxlength="11" id="notify_num" readonly="readonly" class="notify_num" value="<?=$notify_num?>"/>
                <a id="edit_notify_num" href="javascript:">编辑</a>
                <a id="cancel_edit_num" style="display: none;" href="javascript:">取消</a>
                <span id="edit_res"></span>
            </td>
        </tr>
        <tr>
            <th>发送凭证码</th>
            <td>
                <label><input type="radio" name="sendVoucher" value="0" checked="checked"/>是</label>
                <label><input type="radio" name="sendVoucher" value="1" <?if($data_f['sendVoucher']==1)echo 'checked="checked"';?>/>否</label>
                <span class="ui-form-explain">是否发送短信（凭证码)到取票人手机</span>
            </td>
        </tr>
        <tr>
            <th>产品介质</th>
            <td>
                <label><input type="radio" class="vn_middle" value="0" <?=!isset($data)||$data['ifs']==0?'checked="checked"':''?> name="ticketMedia" />电子票</label>
                <label><input type="radio" class="vn_middle" value="1" <?=$data['ifs']==1?'checked="checked"':''?> name="ticketMedia" />实体票（需寄送）</label>
            </td>
        </tr>
        <tr>
            <th>游客信息</th>
            <td>
                <label><input type="radio" name="f[tourist_info]" <?=!$data_f['tourist_info']?'checked="checked"':''?> value="0"/>无需填写</label>
                <label><input type="radio" name="f[tourist_info]" <?=$data_f['tourist_info']==1?'checked="checked"':''?>value="1"/>只需填写一位游客信息</label>
                <label><input type="radio" name="f[tourist_info]" <?=$data_f['tourist_info']==2?'checked="checked"':''?>value="2"/>需填写所有游客信息</label>
                <span class="ui-form-explain">游客信息指游客姓名及身份证号</span>
            </td>
        </tr>
        <tr>
            <th>一次最少</th>
            <td>
                <input type="text" name="blimit_low" class="input-text w40 chknum" value="<?=isset($data) ? $data['buy_limit_low']:'1'?>"/>张
                <span class="ui-form-explain">一次最少购买的票数</span>
            </td>
        </tr>
        <tr>
            <th>一次最多</th>
            <td>
                <input type="text" name="blimit_up" class="input-text w40 chknum " value="<?=isset($data)?$data['buy_limit_up']:'0'?>"/>张
                <span class="ui-form-explain">一次最多购买的票数，填“0”代表不限</span>
            </td>
        </tr>
        </tbody>
    </table>

    <table class="prod_laun" id="price_tb">
        <thead>
        <tr class="header">
            <th colspan="8">
                <span style="float:right;margin-right: 10px;margin-top: 2px; margin-top:0\9">
                    <button type="button" class="newprice ui-button ui-button-sorange">添加</button>
                </span>
                价格/库存配置[<a style="font-size: 12px;font-weight:normal;" target="_blank" href="storageConfig.html?pid=<?=$data['pid']?>">使用“日历模式”</a>]
                <?= $background ? '[<a style="font-size: 12px;font-weight:normal;" href="http://www.16u.cc/d/prod_invalid_price.html?pid='.$prod_id.'&token='.md5(date('Ymd').'cgp').'" target="_blank">历史记录</a>]':''?>
            </th>
        </tr>
        <tr class="bo_btn price_header">
            <th>序号</th>
            <th>适用时间段(同票类不能重复)</th>
            <th>适用日期</th>
            <th class="col4 price_helper" title="产品每天的库存，填“-1”表示不限">日库存</th>
            <th class="col4 price_helper" title="各级分销商最低结算价,单位“元”">供货价</th>
            <th class="col5 price_helper" title="产品限制的最低零售价格,单位“元”">零售价</th>
            <th>门市价</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody id="price_body">
            <?include(TPLPATH.'product_price.html');?>
        </tbody>
    </table>
        <div id="toAppend" class="btnWrap mt10">
            <?=$btnWrap?>
        </div>
    </form>
</div>
<div id="alter-box" class="alter-box">
    <p id="add_result" class="alter-result"><span class="ok"></span><span id="alter-msg" class="alter-msg"></span></p>
    <?if(!$isedit){?>
        <p class="alter-ask">您是否要添加新门票？</p>
        <p>
            <button id="to_ticket_list" back-url="<?=$gourl?>" class="ui-button ui-button-mblue" type="button">返回列表</button>
            &nbsp;&nbsp;
            <button id="add_another_ticket" class="ui-button ui-button-mblue" type="button">继续添加</button>
        </p>
    <?} else {?>
        <p>
            <button id="to_ticket_list" back-url="<?=$gourl?>" class="ui-button ui-button-mblue" type="button">返回列表</button>
            &nbsp;&nbsp;
            <button id="close_dialog" onclick="easyDialog.close();" class="ui-button ui-button-mblue" type="button">关闭</button>
        </p>
    <?}?>
</div>
<script type="text/template" id="sprice">
    <tr id="sprice_{k}">
        <th>{inc}</th>
        <td>
            从<input type="text" data-t="bt" data-msg="请选择时间段" name="ticket[{k}][bt]" readonly="readonly" class="required input-text w66" onfocus="SelectDate(this,'yyyy-MM-dd',0,0)"/>
            至<input type="text" data-t="et" data-msg="请选择时间段" name="ticket[{k}][et]" readonly="readonly" class="required input-text w66" onfocus="SelectDate(this,'yyyy-MM-dd',0,0)"/>
        </td>
        <td>
            <a href="javascript:" class="date_chk" data-chk="1">全选</a>&nbsp;
            <a href="javascript:" class="date_chk" data-chk="2">平时</a>&nbsp;
            <a href="javascript:" class="date_chk" data-chk="3">周末</a>
            <br/>
            <label><input type="checkbox" name="ticket[{k}][normalDay][0]" checked="checked" class="pday" value="0">日</label>
            <label><input type="checkbox" name="ticket[{k}][normalDay][1]" checked="checked" class="pday" value="1">一</label>
            <label><input type="checkbox" name="ticket[{k}][normalDay][2]" checked="checked" class="pday" value="2">二</label>
            <label><input type="checkbox" name="ticket[{k}][normalDay][3]" checked="checked" class="pday" value="3">三</label>
            <label><input type="checkbox" name="ticket[{k}][normalDay][4]" checked="checked" class="pday" value="4">四</label>
            <label><input type="checkbox" name="ticket[{k}][normalDay][5]" checked="checked" class="pday" value="5">五</label>
            <label><input type="checkbox" name="ticket[{k}][normalDay][6]" checked="checked" class="pday" value="6">六</label>
        </td>
        <td>
            <input type="text" data-t="pp" title="请输入日库存量“-1”不限" value="不限" class="input-text w40 storage" name="ticket[{k}][storage]">
        </td>
        <td>
           <input type="text" data-t="pp" data-msg="请输入供货价"  class="required input-text w40" name="ticket[{k}][pg]">
        </td>
        <td>
           <input type="text" data-t="sp" data-msg="请输入零售价" class="required input-text w40" name="ticket[{k}][pl]">
        </td>
        <td>
            &nbsp;
        </td>
        <td><a href="javascript:"  data-rid="{k}" class="remvPrice">删除</a></td>
    </tr>
</script>
<script type="text/javascript">
function instTR(){
   var tab=document.getElementById('tab');
   var n=document.getElementById('x').rowIndex+1;
   var tr=tab.insertRow(n);
   var td=tr.insertCell(0);
   var th=tr.insertCell(0);
   th.innerHTML="<div class=\"th_th\"><th>取消费用</th></div>";
   td.innerHTML="<td>游玩日期前 <input type='text' name='reb_days[]' class='input-text w40 chknum' value='<?=$val['days']?>'/> 天&nbsp;收取  <input type='text' name='reb_cost[]' class='input-text w40 chknum' value='<?=$val['cost']?>'/><span class='number_style'></span><span class='number_style'>&nbsp;&nbsp;%  </span><span class='ui-form-explain'>取消订单需要收取的费用百分比，填写“-1”代表所有日期</span><a href=\"javascript:\" class=\"del\" >删除</a></td>";
    $(".del").live('click',function(){
        $(this).parents("tr").remove();
    });          
}

function check(){
    var r=document.getElementById("testtt").value;
    if (r=='0'){
        document.getElementById("num_style").style.color="#000000";
        document.getElementById("yuan_style").style.color="#ffffff";
    }else{
        document.getElementById("yuan_style").style.color="#000000";
        document.getElementById("num_style").style.color="#ffffff";
    }
}
window.onload = function(){
    check();
}
</script>
<script src="http://www.12301.cc/js/easydialog.min.js" type="text/javascript"></script>
<script src="http://www.12301.cc/js/ticket_edit.add.js" type="text/javascript"></script>
<script src="http://www.12301.cc/js/prod_pub.js" type="text/javascript"></script>
<script src="http://www.12301.cc/js/prod_editk_tar_v3.js?20130816" type="text/javascript"></script>
<script type="text/javascript" src="http://www.12301.cc/js/Calendar.js"></script>
<?
include('common/footer.html');
?>